﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Automobile.service.BLL;
using Automobile.service.Model;
using System.Web.SessionState;

namespace Automobile.service.UI.Hander
{
    /// <summary>
    /// AddShipMents 的摘要说明
    /// </summary>
    public class AddShipMents : IHttpHandler, IRequiresSessionState
    {
        ShipmentsBLL bll = new ShipmentsBLL();
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            Shipments sp = new Shipments();
            sp.Shipments_blitems = context.Request["Shipmentsblitems"];
            sp.Shipments_Per = context.Request["ShipmentsPer"];
            sp.Shipments_Por = context.Request["ShipmentsPor"];
            sp.Shipments_Peosor = context.Request["ShipmentsPeosor"];
            sp.MemberCard_Id = Convert.ToInt32(context.Request["MemberCardId"]);
            sp.WareHose_Id = Convert.ToInt32(context.Request["WareHoseId"]);
            sp.Shipments_Price = Convert.ToDecimal(context.Request["ShipmentsPrice"]);
            sp.Shipments_Pricepor = Convert.ToDecimal(context.Request["ShipmentsPricepor"]);
            sp.Shipments_Remark = context.Request["ShipmentsRemark"];
            string xml = context.Server.UrlDecode(context.Request.Form["xml"].ToString());
            int i = Convert.ToInt32(bll.AddShioments(sp, xml));
            context.Response.Write(i);
            if (i > 0)
            {
                JournalBLL jbll = new JournalBLL();
                jbll.AddJourna_AddShioments(Convert.ToInt32(context.Session["empid"]), sp);
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}